package com.programmer.common.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultData<T> {
    private boolean success;
    private String msg;
    private T data;
    private int errorCode;

    public static ResultData success(){
        return new ResultData(true,"处理成功",null,0);
    }

    public static <T>ResultData success(T data){
        return new ResultData(true,"处理成功",data,0);
    }

    public static <T>ResultData success(T data,String msg){
        return new ResultData(true,msg,data,0);
    }

    public static ResultData fail(String msg){
        return new ResultData(false,msg,null,0);
    }

    public static ResultData fail(String msg,int errorCode){
        return new ResultData(false,msg,null,errorCode);
    }

}
